﻿// -----------------------------------------------------------------------
// <copyright file="Tile.xaml.cs" company="R&R">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

#region Imports
using System.Windows;
using System.Windows.Controls;
#endregion Imports

namespace Domino
{
    /// <summary>
    /// Interaction logic for Tile.xaml
    /// </summary>
    public partial class Tile : Button
    {
        #region Properties
        public TileModel TilePairValue
        {
            get { return (TileModel)GetValue(TilePairValueProperty); }
            set { SetValue(TilePairValueProperty, value); }
        }

        public static readonly DependencyProperty TilePairValueProperty =
            DependencyProperty.Register("TilePairValue", typeof(TileModel), typeof(Tile), new FrameworkPropertyMetadata(OnTilePairValueChanged));

        private static void OnTilePairValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var tile = d as Tile;
            var tileModel = (TileModel)e.NewValue;
            if (tile != null) tile.DataContext = tileModel;
        }
        #endregion Properties

        #region Constructors
        public Tile()
        {
            InitializeComponent();
        }
        #endregion Constructors
    }
}
